package fantasyfootball.data.entities;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 * Class: 605.441 
 * Group: Richard Koretke, Kay Jantharasorn, Israel Rivera.
 * 
 * @author Israel Rivera
 * 
 */
@Entity(name="NFLTeam")
public class NFLTeam implements Serializable{
	
	private static final long serialVersionUID = 7178733839859089720L;
	
	private String teamName;
	private String location;
	private String conference;
	private String division;
	
	private Set<NFLPlayer> teamPlayers;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="TeamName",nullable=false)
	public String getTeamName() {
		return teamName;
	}
	
	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}
	
	@Column(name="Location", nullable=false)
	public String getLocation() {
		return location;
	}
	
	public void setLocation(String location) {
		this.location = location;
	}
	
	@Column(name="Conference", nullable=false)
	public String getConference() {
		return conference;
	}
	
	public void setConference(String conference) {
		this.conference = conference;
	}
	
	@Column(name="Division", nullable=false)
	public String getDivision() {
		return division;
	}
	
	public void setDivision(String division) {
		this.division = division;
	}
	
	@OneToMany(fetch=FetchType.LAZY, mappedBy="nflTeam")
	public Set<NFLPlayer> getTeamPlayers() {
		return teamPlayers;
	}
	
	public void setTeamPlayers(Set<NFLPlayer> teamPlayers) {
		this.teamPlayers = teamPlayers;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((teamName == null) ? 0 : teamName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		NFLTeam other = (NFLTeam) obj;
		if (teamName == null) {
			if (other.teamName != null)
				return false;
		} else if (!teamName.equals(other.teamName))
			return false;
		return true;
	}
}